#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int N = 7e5 + 10;
int n, s[N];

int get_min() {
	for (int i = 1; i <= n; i++) s[n + i] = s[i];
	int i = 1, j = 2, k = 0;
	while (i <= n && j <= n) {
		for (k = 0; k < n && s[i + k] == s[j + k]; k++);
		if (s[i + k] > s[j + k]) i = i + k + 1;
		else j = j + k + 1;
		if (i == j) j++;
	}
	return min(i, j);
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> s[i];
	int k = get_min();
	for (int i = 0; i < n; i++) {
		cout << s[k + i] << " ";
	}
	return 0;
}